package com.jiang.专题.贪心.Q179;

import java.util.PriorityQueue;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/24 13:48
 */
class Solution {
    public String largestNumber(int[] nums) {
        PriorityQueue<String> q = new PriorityQueue<>((a, b) -> ((b + a).compareTo(a + b)));
        for (int num: nums) {
            q.offer(String.valueOf(num));
        }
        StringBuilder sb = new StringBuilder();
        while (!q.isEmpty()) {
            sb.append(q.poll());
        }
        if (sb.charAt(0) == '0') return "0";
        return sb.toString();
    }
}